<template>
  <div>
    <table>
      <tr 
      v-for="(item, index) in goodsArr" 
      :key="index"
      :item="item"
      is="Row"></tr>
    </table>
    <p>All Number:{{ sum }}</p>
  </div>
</template>

<script>
import Row from "./components/Row.vue";

export default {
  components: {
    Row
  },
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
    };
  },
  computed: {
    sum() {
      let total = 0
      this.goodsArr.forEach(item => total += item.count)
      return total
      
    }
  }
};
</script>

<style>
</style>